package com.bawei.network

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import java.util.concurrent.TimeUnit

/**
 * @author ZhangRuiPeng
 * @description:
 */
abstract class RetrofitCreateImpl : RetrofitCreate{

    abstract fun readTime():Long
    abstract fun writeTime():Long
    abstract fun connectTime():Long

    fun createOkBuilder(): OkHttpClient.Builder{
        val builder = OkHttpClient.Builder()
        var logIntercepter = HttpLoggingInterceptor()
        logIntercepter.setLevel(HttpLoggingInterceptor.Level.BODY)
        builder.addInterceptor(logIntercepter)
        builder.readTimeout(readTime(), TimeUnit.SECONDS)
        builder.connectTimeout(connectTime(),TimeUnit.SECONDS)
        builder.writeTimeout(writeTime(),TimeUnit.SECONDS)
        return builder
    }

}